package view.toolbar
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	public class DiceShake extends Sprite
	{
		private var _shake:UIShake;
		public function DiceShake()
		{
			_shake = new UIShake;
			super();
		}
		
		public function play():void{
			_shake.gotoAndPlay(1);
			this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		
		private function onEnterFrame(e:Event):void
		{
			if (_shake.currentFrame == _shake.totalFrames){
				this.addEventListener(Event.ENTER_FRAME, onEnterFrame);	
				this.dispatchEvent(new Event(Event.COMPLETE));
			}
		}
	}
}